//
//  DKWCreditLevelViewController.m
//  CreditHub
//
//  Created by chenglang on 2024/9/17.
//

#import "DKWCreditLevelViewController.h"
#import "CircleProgressView.h"
#import "LoadDetailsViewController.h"
#import "DKWCredApplyViewController.h"

@interface DKWCreditLevelViewController ()
@property (nonatomic ,strong)CircleProgressView *progressView;
@property (nonatomic ,strong) UILabel *labelNumer;
@property (nonatomic ,strong) UIImageView *imgView;
@end

@implementation DKWCreditLevelViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.ch_title = @"Credit level";
    self.layoutBgHeader.constant = 221+SYS_TopHeight;
    
    UIView *view = [[UIView alloc] init];
    view.backgroundColor = UIColor.whiteColor;
    view.cornerRadius = 90;
    [self.view addSubview:view];
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(SYS_TopHeight);
        make.height.width.mas_equalTo(180);
    }];
    
    self.progressView = [[CircleProgressView alloc] initWithFrame:CGRectMake(15, 15, 150, 150)];
    self.progressView.backgroundColor = UIColor.whiteColor;
    self.progressView.progress = self.number.integerValue / 1000.0;
    [view addSubview:self.progressView];
    
    self.layoutWidth.constant = self.progressView.progress * (SCREEN_WIDTH-110);
    
    self.labelNumer = [[UILabel alloc] init];
    self.labelNumer.text = self.number;
    self.labelProgress.text = self.number;
    self.labelNumer.font = [UIFont systemFontOfSize:24 weight:UIFontWeightMedium];
    [view addSubview:self.labelNumer];
    [self.labelNumer mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.centerY.mas_equalTo(-20);
    }];
    
    self.imgView = [[UIImageView alloc] init];
    self.imgView.image = [UIImage imageNamed:@"xypj_xiaolian"];
    [view addSubview:self.imgView];
    [self.imgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(self.labelNumer.mas_bottom).offset(5);
        make.height.width.mas_equalTo(45);
    }];
    
    if(self.number.integerValue == 0){
        [self.buttonNext setTitle:@"Let's evaluate" forState:UIControlStateNormal];
    }else{
        [self.buttonNext setTitle:@"Loan immediately" forState:UIControlStateNormal];
    }
}
- (IBAction)clickNext:(id)sender {
    
    if(self.number.integerValue == 0){
        
        DKWCredApplyViewController *vc = [[DKWCredApplyViewController alloc] init];
        [[UIView xhl_getTopViewController].navigationController pushViewController:vc animated:YES];
        
    }else{
//        LoadDetailsViewController *vc = [[LoadDetailsViewController alloc] init];
//        vc.detailId =self.detailId;
//        [[UIView xhl_getTopViewController].navigationController pushViewController:vc animated:YES];
        [self.navigationController popViewControllerAnimated:YES];
    }
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
